<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.4: http://docutils.sourceforge.net/" />
<title>Collection</title>
<meta name="author" content="Rodrigo Fonseca, Omprakash Gnawali, Kyle Jamieson, and Philip Levis" />
<style type="text/css">

/*
:Author: David Goodger
:Contact: goodger@users.sourceforge.net
:date: $Date: 2009-02-03 23:07:32 $
:version: $Revision: 1.15 $
:copyright: This stylesheet has been placed in the public domain.

Default cascading style sheet for the HTML output of Docutils.
*/
body {
  font-family: Times;
  font-size: 16px;
}

.first {
  margin-top: 0 ! important }

.last {
  margin-bottom: 0 ! important }

.hidden {
  display: none }

a.toc-backref {
  text-decoration: none ;
  color: black }

blockquote.epigraph {
  margin: 2em 5em ; }

dd {
  margin-bottom: 0.5em }

div.abstract {
  margin: 2em 5em }

div.abstract p.topic-title {
  font-weight: bold ;
  text-align: center }

div.attention, div.caution, div.danger, div.error, div.hint,
div.important, div.note, div.tip, div.warning, div.admonition {
  margin: 2em ;
  border: medium outset ;
  padding: 1em }

div.attention p.admonition-title, div.caution p.admonition-title,
div.danger p.admonition-title, div.error p.admonition-title,
div.warning p.admonition-title {
  color: red ;
  font-weight: bold ;
  font-family: sans-serif }

div.hint p.admonition-title, div.important p.admonition-title,
div.note p.admonition-title, div.tip p.admonition-title,
div.admonition p.admonition-title {
  font-weight: bold ;
  font-family: sans-serif }

div.dedication {
  margin: 2em 5em ;
  text-align: center ;
  font-style: italic }

div.dedication p.topic-title {
  font-weight: bold ;
  font-style: normal }

div.figure {
  margin-left: 2em }

div.footer, div.header {
  font-size: smaller }

div.line-block {
  display: block ;
  margin-top: 1em ;
  margin-bottom: 1em }

div.line-block div.line-block {
  margin-top: 0 ;
  margin-bottom: 0 ;
  margin-left: 1.5em }

div.sidebar {
  margin-left: 1em ;
  border: medium outset ;
  padding: 0em 1em ;
  background-color: #ffffee ;
  width: 40% ;
  float: right ;
  clear: right }

div.sidebar p.rubric {
  font-family: sans-serif ;
  font-size: medium }

div.system-messages {
  margin: 5em }

div.system-messages h1 {
  color: red }

div.system-message {
  border: medium outset ;
  padding: 1em }

div.system-message p.system-message-title {
  color: red ;
  font-weight: bold }

div.topic {
  margin: 2em }

h1 {
  font-family: Arial, sans-serif;
  font-size: 20px;
}

h1.title {
 text-align: center;
 font-size: 32px;
}

h2 {
 font-size: 16px;
 font-family: Arial, sans-serif;
}

h2.subtitle {
  text-align: center }

h3 {
 font-size: 12px;
 font-family: Arial, sans-serif;
}

hr {
  width: 75% }

ol.simple, ul.simple {
  margin-bottom: 1em }

ol.arabic {
  list-style: decimal }

ol.loweralpha {
  list-style: lower-alpha }

ol.upperalpha {
  list-style: upper-alpha }

ol.lowerroman {
  list-style: lower-roman }

ol.upperroman {
  list-style: upper-roman }

p.attribution {
  text-align: right ;
  margin-left: 50% }

p.caption {
  font-style: italic }

p.credits {
  font-style: italic ;
  font-size: smaller }

p.label {
  white-space: nowrap }

p.rubric {
  font-weight: bold ;
  font-size: larger ;
  color: maroon ;
  text-align: center }

p.sidebar-title {
  font-family: sans-serif ;
  font-weight: bold ;
  font-size: larger }

p.sidebar-subtitle {
  font-family: sans-serif ;
  font-weight: bold }

p.topic-title {
  font-weight: bold }

pre.address {
  margin-bottom: 0 ;
  margin-top: 0 ;
  font-family: serif ;
  font-size: 100% }

pre.line-block {
  font-family: serif ;
  font-size: 100% }

pre.literal-block, pre.doctest-block {
  margin-left: 2em ;
  margin-right: 2em ;
  background-color: #eeeeee;
  border-color: #000000;
  border-width: thin; 
  font-size: 14px
}

span.classifier {
  font-family: sans-serif ;
  font-style: oblique }

span.classifier-delimiter {
  font-family: sans-serif ;
  font-weight: bold }

span.interpreted {
  font-family: sans-serif }

span.option {
  white-space: nowrap }

span.option-argument {
  font-style: italic }

span.pre {
  white-space: pre }

span.problematic {
  color: red }

table {
  margin-top: 0.5em ;
  margin-bottom: 0.5em }

table.citation {
  border-left: solid thin gray ;
  padding-left: 0.5ex }

table.docinfo {
  margin: 2em 4em;
}

table.footnote {
  border-left: solid thin black ;
  padding-left: 0.5ex }

td, th {
  padding-left: 0.5em ;
  padding-right: 0.5em ;
  vertical-align: top }

th.docinfo-name, th.field-name {
  font-weight: bold ;
  text-align: left ;
  white-space: nowrap;
  }

h1 tt, h2 tt, h3 tt, h4 tt, h5 tt, h6 tt {
  font-size: 100% }

tt {}

ul.auto-toc {
  list-style-type: none }

</style>
</head>
<body>
<div class="document" id="collection">
<h1 class="title">Collection</h1>
<table class="docinfo" frame="void" rules="none">
<col class="docinfo-name" />
<col class="docinfo-content" />
<tbody valign="top">
<tr class="field"><th class="docinfo-name">TEP:</th><td class="field-body">119</td>
</tr>
<tr class="field"><th class="docinfo-name">Group:</th><td class="field-body">Net2 Working Group</td>
</tr>
<tr class="field"><th class="docinfo-name">Type:</th><td class="field-body">Documentary</td>
</tr>
<tr><th class="docinfo-name">Status:</th>
<td>Final</td></tr>
<tr class="field"><th class="docinfo-name">TinyOS-Version:</th><td class="field-body">&gt; 2.1</td>
</tr>
<tr><th class="docinfo-name">Author:</th>
<td>Rodrigo Fonseca, Omprakash Gnawali, Kyle Jamieson, and Philip Levis</td></tr>
<tr class="field"><th class="docinfo-name">Draft-Created:</th><td class="field-body">09-Feb-2006</td>
</tr>
<tr class="field"><th class="docinfo-name">Draft-Discuss:</th><td class="field-body">TinyOS Developer List &lt;tinyos-devel at mail.millennium.berkeley.edu&gt;</td>
</tr>
</tbody>
</table>
<div class="note">
<p class="first admonition-title">Note</p>
<p class="last">This memo documents a part of TinyOS for the TinyOS Community, and
requests discussion and suggestions for improvements.  Distribution
of this memo is unlimited. This memo is in full compliance with
TEP 1.</p>
</div>
<div class="section">
<h1><a id="abstract" name="abstract">Abstract</a></h1>
<p>The memo documents the interfaces, components, and semantics used by
the collection protocols in TinyOS 2.x. Collection provides
best-effort, multihop delivery of packets to one of a set of
collection points.  There may be multiple collection points in a
network, and in this case the semantics are <em>anycast</em> delivery to at
least one of the collection points. A node sending a packet does not
specify which of the collection points the packet is destined to.  The
union of the paths from each node to one or more of the collection
points forms a set of trees, and in this document we assume that
collection points are the roots of these trees.</p>
</div>
<div class="section">
<h1><a id="introduction" name="introduction">1. Introduction</a></h1>
<p>Collecting data at a base station is a common requirement of sensor
network applications. The general approach used is to build one or
more collection trees, each of which is rooted at a base station. When
a node has data which needs to be collected, it sends the data up the
tree, and it forwards collection data that other nodes send to
it. Sometimes, depending on the form of data collection, systems need
to be able to inspect packets as they go by, either to gather
statistics, compute aggregates, or suppress redundant transmissions.</p>
<p>Collection provides best-effort, multihop delivery of packets to one
of a network's tree roots: it is an <em>anycast</em> protocol. The
semantics are that the protocol will make a reasonable effort to
deliver the message to at least one of the roots in the network. By
picking a parent node, a node implementing the collection protocol
inductively joins the tree its parent has joined.  Delivery is best
effort, and there can be duplicates delivered to one or more roots.
Collection provides no ordering or real-time guarantees, although
specific implementations may extend the basic functionality to do
so.</p>
<p>Given the limited state that nodes can store and a general need for
distributed tree building algorithms, collection protocols encounter
several challenges. These challenges are not unique to collection
protocols. Instead, they represent a subset of common networking
algorithmic edge cases that generally occur in wireless routing:</p>
<blockquote>
<ul class="simple">
<li>Loop detection, for when a node selects one of its descendants as
a next hop.</li>
<li>Duplicate suppression, detecting and dealing with lost
acknowledgments that can cause packets to replicate in the
network, wasting capacity.</li>
<li>Link estimation, evaluating the link quality to single-hop
neighbors.</li>
<li>Self-interference, preventing forwarding packets along the route
from introducing interference for subsequent packets.</li>
</ul>
</blockquote>
<p>While collection protocols can take a wide range of approaches to
address these challenges, the programming interface they provide is
typically independent of these details. The rest of this document
describes a set of components and interfaces for collection services.</p>
</div>
<div class="section">
<h1><a id="collection-interfaces" name="collection-interfaces">2. Collection interfaces</a></h1>
<p>A node can perform four different roles in collection: sender (or
source), snooper, in-network processor, and receiver (or
root). Depending on their role, the nodes use different interfaces to
interact with the collection component.</p>
<p>The collection infrastructure can be multiplexed among independent
applications, by means of a collection identifier. The collection
identifier is used to identify different data traffic at the sender,
intermediate-nodes, or the receiver, much like port number in TCP. All
data traffic, regardless of the collection identifier, use the same
routing topology.</p>
<p>The nodes that generate data to be sent to the root are <em>senders</em>.
Senders use the Send interface [<a class="reference" href="#id1">1</a>] to send data to the root of
the collection tree.  The collection identifier is specified as a
parameter to Send during instantiation.</p>
<p>The nodes that overhear messages in transit are <em>snoopers</em>. The
snoopers use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a snooped
message. The collection identifier is specified as a parameter
to Receive during instantiation.</p>
<p>The nodes can process a packet that is in transit. These in-network
<em>processors</em> use the Intercept interface to receive and update a
packet. The collection identifier is specified as a parameter to
Intercept during instantiation. The Intercept interface has this
signature:</p>
<pre class="literal-block">
interface Intercept {
  event bool forward(message_t* msg, void* payload, uint8_t len);
}
</pre>
<p>Intercept has a single event, Intercept.forward(). A collection
service SHOULD signal this event when it receives a packet to forward.
If the return value of the event is FALSE, then the collection layer
MUST NOT forward the packet. The Intercept interface allows a higher
layer to inspect the internals of a packet and suppress it if needed.
Intercept can be used for duplicate suppression, aggregation, and
other higher-level services. As the handler of Intercept.forward()
does not receive ownership of the packet, it MUST NOT modify the
packet and MUST copy data out of the packet which it wishes to use
after the event returns.</p>
<p>Root nodes that receive data from the network are <em>receivers</em>. Roots
use the Receive interface [<a class="reference" href="#id1">1</a>] to receive a message delivered by
collection. The collection identifier is specified as a parameter to
Receive during instantiation.</p>
<p>The set of all roots and the paths that lead to them form the
collection routing infrastructure in the network.  For any connected
set of nodes implementing the collection protocol there is only one
collection infrastructure, <em>i.e.</em>, all roots in this set active at the
same time are part of the same infrastructure.</p>
<p>The RootControl interface configures whether a node is a
root:</p>
<pre class="literal-block">
interface RootControl {
  command error_t setRoot();
  command error_t unsetRoot();
  command bool isRoot();
}
</pre>
<p>The first two commands MUST return SUCCESS if the node is now in the
specified state, and FAIL otherwise. For example, if a node is already
a root and an application calls RootControl.setRoot(), the call will
return SUCCESS. If setRoot() returns SUCCESS, then a subsequent call
to isRoot() MUST return TRUE. If unsetRoot() returns SUCCESS, then a
subsequent call to isRoot() MUST return FALSE.</p>
</div>
<div class="section">
<h1><a id="collection-services" name="collection-services">3 Collection Services</a></h1>
<p>A collection service MUST provide one component, CollectionC,
which has the following signature:</p>
<pre class="literal-block">
configuration CollectionC {
  provides {
    interface StdControl;
    interface Send[uint8_t client];
    interface Receive[collection_id_t id];
    interface Receive as Snoop[collection_id_t];
    interface Intercept[collection_id_t id];
    interface RootControl;
    interface Packet;
    interface CollectionPacket;
  }
  uses {
    interface CollectionId[uint8_t client];
  }
}
</pre>
<p>CollectionC MAY have additional interfaces. All outgoing invocations
(commands for uses, events for provides) of those interfaces MUST have
default functions. Those default functions enable CollectionC to
operate properly even when the additional interfaces are not wired.</p>
<p>Components SHOULD NOT wire to CollectionC.Send. The generic
component CollectionSenderC (described in section 3.1) provides
a virtualized sending interface.</p>
<p>Receive, Snoop, and Intercept are all parameterized by
collection_id_t. Each collection_id_t corresponds to a different
protocol operating on top of collection, in the same way that
different am_id_t values represent different protocols operating on
top of active messages. All packets sent with a particular
collection_id_t generally SHOULD have the same payload format, so that
snoopers, intercepters, and receivers can parse them properly.</p>
<p>ColletionC MUST NOT signal Receive.receive on non-root
nodes. CollectionC MUST signal Receive.receive on a root node when a
unique (non-duplicate) data packet successfully arrives at that
node. It MAY signal Receive.receive when a duplicate data packet
successfully arrives. If a root node calls Send, CollectionC MUST
treat it as it if were a received packet.  Note that the buffer
swapping semantics of Receive.receive, when combined with the pass
semantics of Send, require that CollectionC make a copy of the buffer
if it signals Receive.receive.</p>
<p>If CollectionC receives a data packet to forward and it is not a root
node, it MAY signal Intercept.forward. CollectionC MAY signal
Snoop.receive when it hears a packet which a different node is
supposed to forward. For any given packet it receives, CollectionC
MUST NOT signal more than one of the Snoop.receive, Receive.receive,
and Intercept.forward events.</p>
<p>RootControl allows a node to be made a collection tree root.
CollectionC SHOULD NOT configure a node as a root by default.</p>
<p>Packet and CollectionPacket allow components to access collection
data packet fields [<a class="reference" href="#id1">1</a>].</p>
<div class="section">
<h2><a id="collectionsenderc" name="collectionsenderc">3.1 CollectionSenderC</a></h2>
<p>Collection has a virtualized sending abstraction, the generic
component CollectionSenderC:</p>
<pre class="literal-block">
generic configuration CollectionSenderC(collection_id_t collectid) {
  provides {
    interface Send;
    interface Packet;
  }
}
</pre>
<p>This abstraction follows a similar virtualization approach to
AMSenderC [<a class="reference" href="#id1">1</a>], except that it is parameterized by a collection_id_t
rather than an am_id_t. As with am_id_t, every collection_id_t SHOULD
have a single packet format, so that receivers can parse a packet
based on its collection ID and contents.</p>
</div>
</div>
<div class="section">
<h1><a id="implementation" name="implementation">4. Implementation</a></h1>
<p>Implementations of collection can be found in
<tt class="docutils literal"><span class="pre">tinyos-2.x/tos/lib/net/ctp</span></tt> and <tt class="docutils literal"><span class="pre">tinyos-2.x/tos/lib/net/lqi</span></tt>.
The former is the Collection Tree Protocol (CTP), described in TEP 123
[<a class="reference" href="#id2">2</a>]. The latter is a TinyOS 2.x port of MultihopLqi, a
CC2420-specific collection protocol in TinyOS 1.x.</p>
</div>
<div class="section">
<h1><a id="author-addresses" name="author-addresses">5. Author Addresses</a></h1>
<div class="line-block">
<div class="line">Rodrigo Fonseca</div>
<div class="line">473 Soda Hall</div>
<div class="line">Berkeley, CA 94720-1776</div>
<div class="line"><br /></div>
<div class="line">phone - +1 510 642-8919</div>
<div class="line">email - <a class="reference" href="mailto:rfonseca&#64;cs.berkeley.edu">rfonseca&#64;cs.berkeley.edu</a></div>
<div class="line"><br /></div>
<div class="line"><br /></div>
<div class="line">Omprakash Gnawali</div>
<div class="line">Ronald Tutor Hall (RTH) 418</div>
<div class="line">3710 S. McClintock Avenue</div>
<div class="line">Los Angeles, CA 90089</div>
<div class="line"><br /></div>
<div class="line">phone - +1 213 821-5627</div>
<div class="line">email - <a class="reference" href="mailto:gnawali&#64;usc.edu">gnawali&#64;usc.edu</a></div>
<div class="line"><br /></div>
<div class="line"><br /></div>
<div class="line">Kyle Jamieson</div>
<div class="line">The Stata Center</div>
<div class="line">32 Vassar St.</div>
<div class="line">Cambridge, MA 02139</div>
<div class="line"><br /></div>
<div class="line">email - <a class="reference" href="mailto:jamieson&#64;csail.mit.edu">jamieson&#64;csail.mit.edu</a></div>
<div class="line"><br /></div>
<div class="line"><br /></div>
<div class="line">Philip Levis</div>
<div class="line">358 Gates Hall</div>
<div class="line">Computer Science Laboratory</div>
<div class="line">Stanford University</div>
<div class="line">Stanford, CA 94305</div>
<div class="line"><br /></div>
<div class="line">phone - +1 650 725 9046</div>
<div class="line">email - <a class="reference" href="mailto:pal&#64;cs.stanford.edu">pal&#64;cs.stanford.edu</a></div>
</div>
</div>
<div class="section">
<h1><a id="citations" name="citations">6. Citations</a></h1>
<table class="docutils footnote" frame="void" id="id1" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a name="id1">[1]</a></td><td>TEP 116: Packet Protocols.</td></tr>
</tbody>
</table>
<table class="docutils footnote" frame="void" id="id2" rules="none">
<colgroup><col class="label" /><col /></colgroup>
<tbody valign="top">
<tr><td class="label"><a name="id2">[2]</a></td><td>TEP 123: The Collection Tree Protocol (CTP).</td></tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
